import { House } from "../types/base"

export class hostApi {
    public static async addHouse(payload: House) {
        return (await window.fetch('/host/addHouse', {
            method: 'post',
            body: JSON.stringify(payload),
            headers: {
                'content-type': 'application/json'
            }
        })
            .then(r => {
                return r.json()
            })
            .then(j => {
                return j
            })
        )
    }

    public static async getHouse() {
        return (await window.fetch('/host/gethouse', {
        })
            .then(r => {
                return r.json()
            })
            .then(j => {
                return j
            })
        )
    }
    public static async addPic(payload: {
        url: string,
        houseID: number,
        width?: number,
        height?: number
    }) {
        return (await window.fetch('/host/addPic', {
            method: 'post',
            body: JSON.stringify(payload),
            headers: {
                'content-type': 'application/json'
            }
        })
            .then(r => {
                return r.json()
            })
            .then(j => {
                return j
            })
        )
    }
    public static async getRole() {
        return (await window.fetch('/user/getRole', {
            method: 'post',
            headers: {
                'content-type': 'application/json'
            }
        })
            .then(r => {
                return r.json()
            })
            .then(j => {
                return j
            })
        )
    }
    public static async getMeet() {
        return (await window.fetch('/host/getMeet', {
            method: 'post',
        })
            .then(r => {
                return r.json()
            })
            .then(j => {
                return j
            })
        )
    }
}